<template>
  <div>
    <el-dialog v-loading.lock="loading"
      :append-to-body="true"
      :title="title"
      align="center"
      :close-on-click-modal="false"
      :visible.sync="innerDialogFormVisible"
      @closed="closeDialog">
      <p slot="title">{{ title }}</p>
      <el-form ref="formData"
        :model="formData"
        :rules="formDataRules"
        label-width="120px"
        status-icon>
        <el-row>
          <el-col :span="24">
            <el-form-item label="生产日期"
              prop="dateManufacture">
              <el-date-picker v-model="formData.dateManufacture"
                type="date"
                placeholder="请选择"
                format="yyyy-MM-dd"
                value-format="yyyy-MM-dd" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer"
        class="dialog-footer"
        align="center">
        <el-button type="primary"
          @click="onSubmit('formData')">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "StorageOrderInDateManufacture",
  components: {
  },
  props: {
    dialogDateManufactureVisible: {
      type: Boolean,
      default: false,
    }
  },
  data() {
    return {
      title: '批量设置生产日期',
      loading: false,
      innerDialogFormVisible: false,
      formData: {
        dateManufacture: ''
      },
      formDataRules: {
        dateManufacture: [
          {
            required: true,
            trigger: "change",
            validator: this.Helper.validateFunction,
          },
        ]
      }
    };
  },
  watch: {
  },
  created() {
    this.innerDialogFormVisible = this.dialogDateManufactureVisible;
  },
  methods: {
    cancel() {
      this.innerDialogFormVisible = false;
      this.$emit("update:dialogDateManufactureVisible", false);
    },
    closeDialog() {
      this.cancel();
    },
    onSubmit() {
      this.$refs.formData.validate((valid) => {
        if (valid) {
          this.$emit('batchSetDateManufacture', { dateManufacture: this.formData.dateManufacture });
          this.closeDialog()
        }
      })
    }
  },
};
</script>
<style lang="scss"></style>
